#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


int main(int argc, char **argv)
{
	int fd_read,fd_read2,fd_write,count;
	if((fd_read=open("./data", O_RDONLY))==-1)
	   exit(1);

	if((fd_write=open("./data", O_WRONLY))==-1)
		exit(1);

	if((fd_read2=open("./data", O_RDONLY))==-1)
		exit(1);

	char buf[21] ={0};

	if((count=read(fd_read, buf, 20))==-1)
		exit(1);
	printf("%s %d\n", buf, count);

	memset(buf, 0, 21);

	strcpy(buf, "testing 123....");

	if((count=write(fd_write, buf, strlen(buf)))==-1)
		exit(1);
	
	printf("write:%d\n", count);
	memset(buf, 0, 21);
	
	if((count=read(fd_read2, buf, 20))==-1)
		exit(1);

	printf("%s %d\n", buf, count);

	close(fd_read2);
	close(fd_read);
	close(fd_write);
	return 0;
}
